package me.zhengjie.gas.proto.send;

import me.zhengjie.gas.proto.TankerComm;

/**
 * 加油PC机回应接收成交数据结果命令B2H
 */
public class B2Comm extends TankerComm {

    private long POS_TTC;

    private byte state = 0x01;

    public B2Comm() {
        Cmd = (byte) 0xB2;
    }


    @Override
    public byte[] encode() {
        byte[] data = new byte[6];
        data[0] = Cmd;

        // POS-TTC
        byte a1 = (byte) (POS_TTC / 1000);
        byte a2 = (byte) ((POS_TTC % 1000) / 100);
        byte a3 = (byte) ((POS_TTC % 100) / 10);
        byte a4 = (byte) (POS_TTC % 10);
        data[1] = (byte) ((a1 << 4) | a2);
        data[2] = (byte) ((a3 << 4) | a4);

        // STATUS
        data[3] = state;

        setDATA(data);
        return super.encode();
    }

    public void setPOS_TTC(long POS_TTC) {
        this.POS_TTC = POS_TTC;
    }

    public long getPOS_TTC() {
        return POS_TTC;
    }

    public byte getState() {
        return state;
    }

    public void setState(byte state) {
        this.state = state;
    }
}
